package com.luban.postprocessor;

import org.springframework.beans.BeansException;
import org.springframework.beans.PropertyValues;
import org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessor;
import org.springframework.stereotype.Component;

@Component
public class MyInstantiationAwareBeanPostProcessor implements InstantiationAwareBeanPostProcessor {

	@Override
	public Object postProcessBeforeInstantiation(Class<?> beanClass, String beanName) throws BeansException {
		System.out.println(beanName + ":MyInstantiationAwareBeanPostProcessor:postProcessBeforeInstantiation 实例之前 " + beanClass);
		return null;
	}

	@Override
	public boolean postProcessAfterInstantiation(Object bean, String beanName) throws BeansException {
		System.out.println(beanName + ":MyInstantiationAwareBeanPostProcessor:postProcessAfterInstantiation 实例之后 " + bean);
		return true;
	}

	@Override
	public PropertyValues postProcessProperties(PropertyValues pvs, Object bean, String beanName) throws BeansException {
		System.out.println(beanName + ":MyInstantiationAwareBeanPostProcessor:postProcessProperties 属性处理，一般处理@Autowired、@Resource、@Value等注解 " + bean);
		return pvs;
	}

}
